﻿@using KRM.Core.General
@model IEnumerable<KRM.Core.tblKRMWPostComment>
@if (Model.Count() > 3)
{
    <div class="readmorecomment"><a href="javascript:;" onclick="seeallcomments(@ViewBag.PostId)">See more @Model.Skip(3).Count() other comments</a></div>
}
@foreach (var item in Model.Take(3))
{
    var user = item.User;
    <div class="formcomment commentitem">
        <div class="commentavatar">
            <a href="?author=@item.CommentByUserId" title="@user.Username">
                <img src="/Upload/Avatar/@(user.Avatar ?? "user-default.png")" onerror="this.src='/upload/avatar/user-default.png'" alt="@user.Username"/>
            </a>
        </div>
        <div class="commentcontent">
            <div>
                <a href="?author=@item.CommentByUserId" title="@user.Username" style="margin-right: 10px" class="bold">@user.Username</a>
                <span class="timeago">@General.TimeAgo(item.CommentDate.To<DateTime>())</span>
                @if (user.UserID == item.CommentByUserId)
                {
                    <div class="deletecomment" onclick="deletecomment('@item.CommentId', '@item.PostId')" title="Delete comment"></div>
                }
            </div>
            <div class="commenttext">
                @Html.Raw(item.Content.Replace("\r\n", "<br />"))
            </div>
        </div>
    </div>
}